String[] initialized by null???

Posted by Esmond on Stack Overflow See other posts from Stack Overflow or by Esmond
Published on 2010-04-14T15:04:40Z Indexed on 2010/04/14 15:13 UTC
Read the original article Hit count: 112

Filed under:

Hi i encountered this problem whereby when i initialized my String[], there seems to be a null in the String[] before i do anything. How do i initialized the String[] to be completely empty,i.e. without the null at the start? The output for the following code is:
nullABC
nullABC
nullABC
nullABC
nullABC

public static void main(String[] args){
    String[] inputArr = new String[5];
    for (int i = 0; i< inputArr.length; i++){
        inputArr[i] += "ABC";
    }
    for (int i = 0; i< inputArr.length; i++){
        System.out.println(inputArr[i]);
    }
}

}

© Stack Overflow or respective owner

Related posts about java